﻿Imports DevExpress.XtraSplashScreen
Imports DevExpress.XtraEditors

Public Class DonDatHang
    Private Sub LoadDuLieu()
        SplashScreenManager.ShowForm(GetType(WaitForm1))
        Me.MHDonDatHangTableAdapter.Fill(Me.PCV_CLINICDataSet.MHDonDatHang)
        Me.MHDonDatHangChiTietTableAdapter.Fill(Me.PCV_CLINICDataSet.MHDonDatHangChiTiet)
        Me.DMKhachHangTableAdapter.Fill(Me.PCV_CLINICDataSet_Don.DMKhachHang)
        Me.TinhTrangTableAdapter.Fill(Me.PCV_CLINICDataSet_Don.TinhTrang)
        Me.DMHangHoaTableAdapter.Fill(Me.PCV_CLINICDataSet.DMHangHoa)
        SplashScreenManager.CloseForm()
    End Sub
    Public Overrides Sub setSubTruoc_Luu()
        Me.setSuaTruocKhiLuuTab1("madondathang", Me.MadondathangITextEdit.EditValue)
        Me.setSuaTruocKhiLuuTab1("ngaylap", Me.NgaylapIDateEdit.EditValue)
    End Sub
    Public Overrides Sub setSubSau_TaoMoi()
        Me.TinhtrangISearchLookupEdit.EditValue = "1"
    End Sub
    Private Sub DonDatHang_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        LoadDuLieu()
    End Sub
    Public Sub New()
        InitializeComponent()
        Me.setSoTabThamChieu(0)
        Me.setSoTab(1)
        Me.setObj(Me.PCV_CLINICDataSet, Me.PCV_CLINICDataSet.MHDonDatHang, MHDonDatHangBindingSource, Me.TableAdapterManager, Me.MHDonDatHangTableAdapter, Me.MadondathangITextEdit, TinhtrangISearchLookupEdit)
        Me.setTab1(Me.PCV_CLINICDataSet.MHDonDatHangChiTiet, Me.FKMHDonDatHangma45BE5BA9BindingSource, Me.MHDonDatHangChiTietTableAdapter)
        Me.IGridViewChiTiet01.setBatLoi("soluong", "not 0 and not null")
        Me.IGridViewChiTiet01.setBatLoi("giavnd", "not 0 and not null")
        Me.IGridViewChiTiet01.setBatLoi("thanhtienvnd", "not 0 and not null")
        Me.setColumnsChangeTab1(New ArrayList From {"soluong", "giavnd", "thanhtienvnd"})
        Me.setColumnValueTab1(Me.colEx1ChiTiet01, Me.colthanhtienvnd)
    End Sub
    Private Sub IGridViewChiTiet01_InitNewRow(sender As Object, e As DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs) Handles IGridViewChiTiet01.InitNewRow
        Me.IGridViewChiTiet01.SetFocusedRowCellValue("uid", System.Guid.NewGuid)
        Me.IGridViewChiTiet01.SetFocusedRowCellValue("soluong", 0)
        Me.IGridViewChiTiet01.SetFocusedRowCellValue("giavnd", 0)
        Me.IGridViewChiTiet01.SetFocusedRowCellValue("thanhtienvnd", 0)
        Me.setFlagInitNewRowTab1(True)
    End Sub
    Private Sub ManccISearchLookupEdit_EditValueChanging(sender As Object, e As DevExpress.XtraEditors.Controls.ChangingEventArgs) Handles ManccISearchLookupEdit.EditValueChanging
        Me.TennccITextEdit.EditValue = Me.ManccISearchLookupEdit.getRows("ten").ToString
        Me.DiachinccITextEdit.EditValue = Me.ManccISearchLookupEdit.getRows("diachi").ToString
    End Sub
    Private Sub MansxISearchLookupEdit_EditValueChanging(sender As Object, e As DevExpress.XtraEditors.Controls.ChangingEventArgs) Handles MansxISearchLookupEdit.EditValueChanging
        Me.TennsxITextEdit.EditValue = Me.MansxISearchLookupEdit.getRows("ten").ToString
        Me.DiachinsxITextEdit.EditValue = Me.MansxISearchLookupEdit.getRows("diachi").ToString
    End Sub
    Private Sub RepositoryItemISearchLookUpEdit_DMHangHoa_EditValueChanging(sender As Object, e As DevExpress.XtraEditors.Controls.ChangingEventArgs) Handles RepositoryItemISearchLookUpEdit_DMHangHoa.EditValueChanging
        Dim editor As SearchLookUpEdit = CType(sender, SearchLookUpEdit)
        Dim rowHandle As Integer = editor.Properties.GetIndexByKeyValue(e.NewValue)
        Me.IGridViewChiTiet01.SetFocusedRowCellValue("mahang", editor.Properties.View.GetRowCellValue(rowHandle, "ma"))
        Me.IGridViewChiTiet01.SetFocusedRowCellValue("tenhang", editor.Properties.View.GetRowCellValue(rowHandle, "ten"))
        Me.IGridViewChiTiet01.SetFocusedRowCellValue("donvitinh", editor.Properties.View.GetRowCellValue(rowHandle, "donvitinh"))
    End Sub
End Class
